//
//  MLWSearchOneViewController.m
//  KITCHEN_STORIES
//
//  Created by dllo on 16/6/12.
//  Copyright © 2016年 MLW. All rights reserved.
//

#import "MLWSearchOneViewController.h"
#import "MLWSearchModel.h"
#import "MLWDetailNiceViewController.h"

@interface MLWSearchOneViewController ()<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, retain) UITableView *tableView;

@end

@implementation MLWSearchOneViewController
-(void)dealloc
{
    [_tableView release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 20, ScreenWidth, ScreenHeight - 64 - 49) style:UITableViewStylePlain];
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    [self.view addSubview:_tableView];
    [_tableView release];
    
    UIButton *buttonBack = [UIButton buttonWithType:UIButtonTypeCustom];
    buttonBack.frame = CGRectMake(0, 0, ScreenWidth, 20);
    buttonBack.backgroundColor = [UIColor colorWithRed:0.91 green:0.91 blue:0.91 alpha:1.00];
    
    [buttonBack addTarget:self action:@selector(didClickedButton) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:buttonBack];
    
    //注册:
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];

    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.arrayN.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MLWSearchModel *model = [self.arrayN objectAtIndex:indexPath.row];
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    
    cell.textLabel.text = model.name;
    
    return cell;
}

#pragma mark ------ Cell的点击方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    MLWSearchModel *model = [self.arrayN objectAtIndex:indexPath.row];
    
    
    
    MLWDetailNiceViewController *dvc = [[MLWDetailNiceViewController alloc] init];
    
    [self.navigationController pushViewController:dvc animated:YES];
    
    dvc.lalala = model.id;
    
    [dvc release];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
